var vm = new Vue({
    el: '#app',
    data: {
        list: '', //表格遍历的数据
        num: 1
    },
    created(){
        this.getManager();
    },
    methods:{
        getManager(){
            $.ajax({
                url: 'manager/list',
                success: function (res) {

                    vm.list = res.list;
                    vm.num = 1;

                    //bootstrap 分页
                    var options = {
                        bootstrapMajorVersion: 3,
                        currentPage: res.page,
                        totalPages: res.totalPage,
                        size: "normal",
                        alignment: "center",
                        itemTexts:function(type,page, current){
                            switch (type) {
                                case "first":
                                    return "首页";
                                case "prev":
                                    return "上一页";
                                case "next":
                                    return "下一页";
                                case "last":
                                    return "尾页";
                                case "page":
                                    return page;
                            }
                        },
                        onPageClicked: function (event, originalEvent, type, page) {

                            $.ajax({
                                url:'manager/list', //点击分页提交当前页码
                                data:{
                                    page: page
                                },
                                success:function(data){
                                    vm.list = data.list;
                                    vm.num = (page -1) * 15 + 1;
                                }
                            })
                        }
                    };

                    $("#page").bootstrapPaginator(options);


                }
            });
        }
    },
    filters:{
        statusFormat: function (str) {
            if (str == 1){
                return "有效";
            } else {
                return "冻结";
            }
        }
    }
});